// 商品列表模板
import { saveMicroPage,viewPageByCategory } from '@/api/shoppingMall/feature'
export default {
  name: 'GoodsFeature',
  data() {
    return {
      dataField: {
        category:12,
        styleType: '1',
        showType: 0,
        cartType: '1',
        title: '全部商品',
        description: '',
        styleExData: {
          showGoodsTag: '1', // 商品标签
          showCart: '1',
          showSoldOut: '1', // 售罄标识
          showGoodsSaleNum: '1' // 商品销量
        }
      },
      isSaving: false, // 是否正在保存
      id:''
    }
  },
  mounted () {
    this.getInfo()
  },
  methods: {
    getInfo(){
      viewPageByCategory({ id: 12 }).then(res => {
        if(res !== null){
          this.id = res.id
          this.dataField = res.moduleList[0].dataField
        }

      })
    },
     // 保存
     save(){
      this.isSaving = true
      const moduleList = {
        id: this.id,
        operType: 2,
        moduleList: [{
            type: "config",
            dataField:this.dataField
        }]
      }
      saveMicroPage(moduleList).then(res => {
        this.isSaving = false
        this.$message.success('发布成功')
        this.getInfo()
      })
    },
  }
}
